﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using Cloak.NUnit;
using Cloak.Reflection;
using NUnit.Framework;

namespace Ruleweaver.Rules
{
	public class CreateAndRule : Behavior
	{
		private CheckRule _rule0;
		private CheckRule _rule1;
		private CompositeRule _andRule;

		protected override void Given()
		{
			_rule0 = Rule.Check(Reflect.Func<ICheckable<int>, Check<int>>(Checkable.IsPositive));
			_rule1 = Rule.Check(Reflect.Func<ICheckable<int>, Check<int>>(Checkable.IsOdd));
		}

		protected override void When()
		{
			_andRule = Rule.And(_rule0, _rule1);
		}

		[Then]
		public void RulesAppearInOrder()
		{
			// TODO: Refactor

			Assert.AreEqual(2, _andRule.Rules.Count);
			Assert.AreEqual(_rule0, _andRule.Rules[0]);
			Assert.AreEqual(_rule1, _andRule.Rules[1]);
		}

		[Then]
		public void HasAndType()
		{
			Assert.AreEqual(RuleType.And, _andRule.Type);
		}
	}
}